package basic;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * @author： pang-yun
 * @date： 2021-08-31 15:19
 * 功能目的 ：用于  channel 之间输出数据
 */

public class ChannelTransferTo {

    @Test
    public void transfer(){
        try (FileChannel from = new FileInputStream("G:\\MyProgran\\play\\Netty-demo\\src\\main\\resources\\data.txt").getChannel()) {
            FileChannel to = new FileOutputStream("G:\\MyProgran\\play\\Netty-demo\\src\\main\\resources\\to.txt").getChannel();
            from.transferTo(0,from.size(),to);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
